import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:school_safe_teacher/resourse/app_colors.dart';

Widget body({Widget child, BuildContext context}) {
  return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark,
      child: Scaffold(
          backgroundColor: Colors.white,
          body: Container(
            padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
            child: child,
          )));
}

//带左右边距的布局
Widget getParent({Widget child, BuildContext context}) {
  return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark,
      child: Scaffold(
        backgroundColor: Colors.white,
        body: Container(
          padding: EdgeInsets.fromLTRB(
              12, MediaQuery.of(context).padding.top, 12, 0),
          child: child,
        ),
      ));
}

//沉浸式布局
Widget stateBar({Widget child, BuildContext context}) {
  return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark,
      child: Scaffold(
          backgroundColor: Colors.white,
          body: Container(
            child: child,
          )));
} //带bottombar布局

Widget stateIndexBar({Widget child, BuildContext context}) {
  return AnnotatedRegion<SystemUiOverlayStyle>(
      value: SystemUiOverlayStyle.dark,
      child: Scaffold(
        backgroundColor: Colors.white,
        body: Container(
          child: child,
        ),
        bottomNavigationBar: BottomNavigationBar(
          fixedColor: Colors.red,
          currentIndex: 0,
          items: [
            BottomNavigationBarItem(label: "首页", icon: Icon(Icons.home)),
            BottomNavigationBarItem(label: "我的", icon: Icon(Icons.person))
          ],
          // onTap: (value) {
          //   Navigatin
          // },
        ),
      ));
}

Widget myBar({BuildContext context, String title}) {
  return Row(
    mainAxisAlignment: MainAxisAlignment.center,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: [
      GestureDetector(
        child: Container(
          padding: EdgeInsets.fromLTRB(5, 15, 5, 15),
          child: Image.asset(
            "images/arrow_left@2x.png",
            width: 20,
            height: 20,
          ),
        ),
        onTap: () {
          Navigator.of(context).pop(1);
        },
      ),
      Expanded(
        child: Text(
          title,
          textAlign: TextAlign.center,
          style: TextStyle(
              fontSize: 17,
              color: AppColors.deepTextColor,
              fontWeight: FontWeight.w800),
        ),
      ),
      GestureDetector(
        child: Container(
          padding: EdgeInsets.fromLTRB(5, 15, 5, 15),
          child: Image.asset(
            "",
            width: 20,
            height: 20,
          ),
        ),
      ),
    ],
  );
}

Widget myRightBar({BuildContext context, String title,String rightTitle,ontap()}) {
  return Stack(
    alignment: Alignment.center,
    children: [
      Align(child: GestureDetector(
        child: Container(
          padding: EdgeInsets.fromLTRB(5, 15, 5, 15),
          child: Image.asset(
            "images/arrow_left@2x.png",
            width: 20,
            height: 20,
          ),
        ),
        onTap: () {
          Navigator.of(context).pop(1);
        },
      ),alignment: Alignment.centerLeft,),
      Align(
        child: Text(
          title,
          textAlign: TextAlign.center,
          style: TextStyle(
              fontSize: 17,
              color: AppColors.deepTextColor,
              fontWeight: FontWeight.w800),
        ),
        alignment: Alignment.center,
      ),
      Align(child: GestureDetector(
        child: Container(
          padding: EdgeInsets.fromLTRB(5, 15, 15, 15),
          child: Text(
            rightTitle,
            textAlign: TextAlign.right,
            style: TextStyle(
                fontSize: 14,
                color: AppColors.deepTextColor,
                fontWeight: FontWeight.normal),
          ),
        ),
        onTap: ontap,
      ),alignment: Alignment.centerRight,)
    ],
  );
}

Widget noRightIconBar({BuildContext context, String title}) {
  return  Stack(
    alignment: Alignment.center,
    children: [
      Align(
        child: Container(
          child: Image.asset(
            "images/member_back@2x.png",
            height: 17,
            width: 9,
          ),
          padding: EdgeInsets.only(top: 15, bottom: 15),
        ),
        alignment: Alignment.centerLeft,
      ),
      Align(
          child: Text(
            title,
            style: TextStyle(
                fontWeight: FontWeight.w600,
                fontSize: 17,
                color: AppColors.deepTextColor),
          )),
    ],
  );
}

Widget rightTextBar({BuildContext context, String title,String right,Function onTap}) {
  return  Stack(
    alignment: Alignment.center,
    children: [
      Align(
        child: Container(
          child: Image.asset(
            "images/member_back@2x.png",
            height: 17,
            width: 9,
          ),
          padding: EdgeInsets.only(top: 15, bottom: 15),
        ),
        alignment: Alignment.centerLeft,
      ),
      Align(
          child: Text(
            title,
            style: TextStyle(
                fontWeight: FontWeight.w600,
                fontSize: 17,
                color: AppColors.deepTextColor),
          )),
      Align(
        child: GestureDetector(child: Text(
          right,
          style: TextStyle(
              fontWeight: FontWeight.w600,
              fontSize: 14,
              color: AppColors.middleTextColor),
        ),onTap: onTap,),alignment: Alignment.centerRight,),
    ],
  );
}